package main

import "fmt"

type Dog1 struct {
	name string
	age  int
}

// 方法 需要有调用
func (dog Dog1) eat() {
	fmt.Println(dog.name + "Dog eating")
}
func (dog Dog1) sleep() {
	fmt.Println(dog.name + "Dog sleeping")
}

type Cat1 struct {
	name string
	age  int
}

func (name Cat1) eat() {
	fmt.Println(name.name + "Cat eating")
}
func (name Cat1) sleep() {
	fmt.Println(name.name + "Cat sleeping")
}

func main() {
	cat1 := Cat1{
		name: "哈吉米",
		age:  10,
	}
	cat2 := Cat1{
		name: "cat2",
		age:  20,
	}
	cat2.eat()
	cat1.eat()
	cat1.sleep()

	var dog1 Dog1
	dog1.name = "哈基十"
	dog1.age = 5
	dog1.eat()
	dog1.sleep()
}
